/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [EditMenuPopup.java]
 * Creation Date        [11-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_02_gui.notepad_V1.ui.edit;

import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

/**
 * 弹出菜单
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class EditMenuPopup extends JPopupMenu {

	private static final long serialVersionUID = -6941320647355213038L;

	private ActionListener listener = null;

	/** **********************弹出菜单*********************** */
	private JMenuItem undo;
	private JMenuItem redo;
	private JMenuItem cut;
	private JMenuItem copy;
	private JMenuItem paste;
	private JMenuItem delete;
	private JMenuItem selectAll;

	private void initPopupMenu() {
		undo = new JMenuItem("撤销(Z)");
		undo.setMnemonic('Z');
		undo.addActionListener(listener);
		this.add(undo);

		redo = new JMenuItem("恢复撤销(B)");
		redo.setMnemonic('B');
		redo.addActionListener(listener);
		this.add(redo);

		addSeparator();// 添加分割线

		cut = new JMenuItem("剪切(X)");
		cut.setMnemonic('X');
		cut.addActionListener(listener);
		this.add(cut);

		copy = new JMenuItem("复制(C)");
		copy.setMnemonic('C');
		copy.addActionListener(listener);
		this.add(copy);

		paste = new JMenuItem("粘贴(V)");
		paste.setMnemonic('V');
		paste.addActionListener(listener);
		this.add(paste);

		addSeparator(); // 添加分割线

		delete = new JMenuItem("删除(D)");
		delete.setMnemonic('D');
		delete.addActionListener(listener);
		this.add(delete);

		addSeparator();// 添加分割线

		selectAll = new JMenuItem("全选(A)");
		selectAll.setMnemonic('A');
		selectAll.addActionListener(listener);
		this.add(selectAll);
	}

	public EditMenuPopup(ActionListener listener) {
		this.listener = listener;
		initPopupMenu();
	}

	public JMenuItem getUndo() {
		return undo;
	}

	public JMenuItem getRedo() {
		return redo;
	}

	public JMenuItem getCut() {
		return cut;
	}

	public JMenuItem getCopy() {
		return copy;
	}

	public JMenuItem getPaste() {
		return paste;
	}

	public JMenuItem getDelete() {
		return delete;
	}

	public JMenuItem getSelectAll() {
		return selectAll;
	}

}
